package com.Wayne_04_decorator_pattern;

/*
    装饰类：继承InputStream 扩展原始类功能
*/
public class BufferedInputStream extends InputStream {
    private InputStream is;

    public BufferedInputStream(InputStream is) {
        this.is = is;
    }

    @Override
    public int read() {
        System.out.println("提供8KB的缓冲区，提高读数据性能");
        return is.read();
    }

    @Override
    public int read(byte[] buffer) {
        System.out.println("提供8KB的缓冲区，提高读数据性能");
        return is.read(buffer);
    }
}

